public class Equation {
    Equation(int a,int b,int c){
        this.a=a;
        this.b=b;
        this.c=c;
    }
    int a;
    int b;
    int c;
    double x1;
    double x2;

    boolean solve(){
        if(a==0){
            System.out.println("这不是一元二次方程！");
            return false;
        }else {
            if ((b * b - 4 * a * c) < 0) {
                System.out.println("一元二次方程出错！");
                return false;
            } else {
                x1 = -b + Math.sqrt(b * b - 4 * a * c)/(2*a);
                x2 = -b - Math.sqrt(b * b - 4 * a * c)/(2*a);
            }
        }
        return true;
    }

    void printf(){
        System.out.println("x1="+x1);
        System.out.println("x2="+x2);
    }
}
